using System.Web.Mvc;
using iMade.Model;

namespace iMade.Web.MVC.Controllers
{
    public class DataController : Controller
    {
        //
        // GET: /Data/

        public ActionResult Index()
        {
            return View();
        }

        public JsonResult Rss(string feedUrl)
        {
            Response.AppendHeader("Content-disposition", "attachment; filename=rss.json");
            IBlogReader br = new BlogReader();
            var bpc = br.GetBlogPosts(feedUrl);
            return Json(bpc);
        }

        public JsonResult Calendar(string feedUrl)
        {
            Response.AppendHeader("Content-disposition", "attachment; filename=ics.json");
            ICalendarReader cr = new CalendarReader();
            var cec = cr.GetCalendarEvents(feedUrl);
            return Json(cec);
        }

        public JsonResult Group(string feedUrl)
        {
            Response.AppendHeader("Content-disposition", "attachment; filename=group.json");
            IGroupReader gr = new GroupReader();
            var g = gr.GetGroup(feedUrl);
            return Json(g);
        }

        public JsonResult Groups(string feedUrl)
        {
            Response.AppendHeader("Content-disposition", "attachment; filename=groups.json");
            IGroupReader gr = new GroupReader();
            var gc = gr.GetGroups(feedUrl);
            return Json(gc);
        }

    }
}
